package cn.iocoder.an.module.business.dal.mysql.reportview;

import java.util.*;

import cn.iocoder.an.framework.common.pojo.PageResult;
import cn.iocoder.an.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.an.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.an.module.business.dal.dataobject.reportview.ReportViewDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.an.module.business.controller.admin.reportview.vo.*;

/**
 * 报表汇总 Mapper
 *
 * @author zzy
 */
@Mapper
public interface ReportViewMapper extends BaseMapperX<ReportViewDO> {

    default PageResult<ReportViewDO> selectPage(ReportViewPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReportViewDO>()
                .likeIfPresent(ReportViewDO::getName, reqVO.getName())
                .betweenIfPresent(ReportViewDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReportViewDO::getId));
    }

    default ReportViewDO selectByParentIdAndName(Long parentId, String name) {
        return selectOne(ReportViewDO::getParentId, parentId, ReportViewDO::getName, name);
    }

    default Long selectCountByParentId(Long parentId) {
        return selectCount(ReportViewDO::getParentId, parentId);
    }


}